package tp.pr5;
/**
 * An enum class that represents the compass directions (North, east, south and west) plus a value that represents an unknown direction.
 * @author Carlos Bermúdez y Mario de Benito
 *
 */
public enum Direction {
	NORTH, EAST, SOUTH, WEST, UNKNOWN;
	
	
	/**
	 * Returns the opposite direction
	 * @param crrntDirection
	 * @return opposite direction
	 */
	public Direction getOpposite(){
		
		int crrntOrdinal = this.ordinal();
		int oppositeOrdinal = ((crrntOrdinal%4)+2) % 4;
		if (oppositeOrdinal == 4) oppositeOrdinal = 0;
		return Direction.values()[oppositeOrdinal];
	}
	/**
	 * Returns the direction to the right
	 * @param crrntDirection
	 * @return
	 */
	public Direction getRight(){
		int crrntOrdinal = this.ordinal();
		int oppositeOrdinal = (crrntOrdinal%4) + 1;
		if (oppositeOrdinal == 4) oppositeOrdinal = 0;
		return Direction.values()[oppositeOrdinal];
	}
	/**
	 * Returns the direction to the left
	 * @param crrntDirection
	 * @return
	 */
	public Direction getLeft(){
		int crrntOrdinal = this.ordinal();
		int oppositeOrdinal = (crrntOrdinal%4) - 1;
		if (oppositeOrdinal <0) oppositeOrdinal = 3;
		return Direction.values()[oppositeOrdinal];
	}

}